/**
 * 存放全局公用状态
 */

const state = {
    // 当前选中的分组设备id，用于CefSharp接口调用
    currentGroupDeviceId: null
}

const getters = {
    // 获取当前分组设备id
    getCurrentGroupDeviceId: state => state.currentGroupDeviceId
}

const actions = {
    // 设置当前分组设备id
    setCurrentGroupDeviceId({ commit }, groupDeviceId) {
        console.log('🔄 [Global Store] 设置分组设备id:', groupDeviceId)
        commit('SET_CURRENT_GROUP_DEVICE_ID', groupDeviceId)
    },
    
    // 清除当前分组设备id
    clearCurrentGroupDeviceId({ commit }) {
        console.log('🔄 [Global Store] 清除分组设备id')
        commit('SET_CURRENT_GROUP_DEVICE_ID', null)
    }
}

const mutations = {
    // 设置当前分组设备id
    SET_CURRENT_GROUP_DEVICE_ID(state, groupDeviceId) {
        state.currentGroupDeviceId = groupDeviceId
    }
}

export default {
    namespaced: true,
    state,
    actions,
    getters,
    mutations
}
